package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YCKOKO
 * Date: 2022-10-22
 * Time: 17:05
 */
public class FindOperation implements IOPeration{
    public void work(BookList bookList){
        //查找图书
        System.out.println("查找图书");
        System.out.println("请输入你要查找的图书名称：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int currentSize = bookList.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getPos(i);
            if(name.equals(book.getName())){
                System.out.println("查找图书成功！");
                System.out.println(book);
                return;
                }
            }
        System.out.println("你所要查找的图书不存在");
    }
}
